package com.liyuhan.onlinetaxibackground.Controller;

import com.liyuhan.onlinetaxibackground.Service.ReceivedOrderService;
import com.liyuhan.onlinetaxibackground.dto.DataResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/receivedOrder")
public class ReceivedOrderController {
    @Autowired
    private ReceivedOrderService receivedOrderService;

    @RequestMapping("/getReceivedOrder")
    public DataResponse getReceivedOrder(@Valid @RequestBody String request) {
        // 乘客获取已接收订单
        return receivedOrderService.getReceiverOrder(request);
    }

    @RequestMapping("/verifyPhone_4")
    public DataResponse verifyPhone_4(@Valid @RequestBody String request) {
        // 验证后四位手机号
        return receivedOrderService.verifyPhone_4(request);
    }

    @RequestMapping("/cancelOrderRequest")
    public void cancelOrderRequest(@Valid @RequestBody String request) {
        // 根据订单id发出取消订单申请
        receivedOrderService.cancelOrderRequest(request);
    }

    @RequestMapping("/goingToDestination")
    public void goingToDestination(@Valid @RequestBody String request) {
        // 根据订单id发出取消订单申请
        receivedOrderService.goingToDestination(request);
    }

    @RequestMapping("/getOrderState")
    public DataResponse getOrderState(@Valid @RequestBody String request) {
        // 根据订单id订单状态
        return receivedOrderService.getOrderState(request);
    }

    @RequestMapping("/completeOrder")
    public DataResponse completeOrder(@Valid @RequestBody String request) {
        // 根据订单id和司机手机号来绑定 -》 司机+订单+用户
        return receivedOrderService.completeOrder(request);
    }

    @RequestMapping("/isCanceled")
    public DataResponse isCanceled(@Valid @RequestBody String request) {
        // 根据订单id判断当前订单是否被用户取消并获取取消原因
        return receivedOrderService.isCanceled(request);
    }

    @RequestMapping("/setDriverCancel")
    public DataResponse setDriverCancel(@Valid @RequestBody String request) {
        // 根据订单id设置司机撤销订单的反应
        return receivedOrderService.setDriverCancel(request);
    }

    @RequestMapping("/isAgree")
    public DataResponse isAgree(@Valid @RequestBody String request) {
        // 根据订单id获取司机对撤销订单的反应
        return receivedOrderService.isAgree(request);
    }
}
